﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DigitalAnts.MasterPage;
using System.Drawing;
using BAL.Entities;
using BAL.Components;
using DigitalAnts.App_Code.BAL.Utils;

namespace DigitalAnts.User
{
    public partial class UpdateAvatar : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ((UserLayout)Page.Master).ChangeAvatarHyperLink = false;
                ((UserLayout)Page.Master).ChangeAvatarHyperLinkColor = Color.Red;
                ((UserLayout)Page.Master).UnabelChangeAvatarHyplerLinkUnderline = false;
                clsUser obj = new clsUser();
                obj.UserID = Convert.ToInt32(Session["UserID"]);
                this.imgOldImage.ImageUrl = "../resource/user_avatar/" + clsUserBAL.doGetUserProfile(obj).Avatar;
            }
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (rdNew.Checked)
            {
                clsUser obj = new clsUser();
                string avatar = "defaultAvatar.png";
                if (fulavatar.FileName != null)
                {
                    avatar = fulavatar.FileName;
                    clsUploadImage.uploadProductImage(fulavatar);
                }
                obj.Avatar = avatar;
                if (clsUserBAL.doUpdateUserAvatar(obj) == true)
                {
                    Response.Redirect("~/User/UserPage.aspx");
                }
            }
        }
    }
}